package com.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBHelper {
    public static Connection getConnection() throws ClassNotFoundException, SQLException {
        String user = "sa";
        String password = "123456789";
        String dataBase = "STUDB";
        String host = "localhost:1433";
        String url = "jdbc:sqlserver://" + host + ";databaseName="
                + dataBase + ";user=" + user + ";password=" + password;

        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        return DriverManager.getConnection(url);
    }

    public static void main(String[] args) throws SQLException, ClassNotFoundException {
        Connection connection = getConnection();
        System.out.println(connection);
    }
}
